package cn.msqweb.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
 
@Service
public class MyService {
 
    private final ApplicationContext context;
 
    @Autowired
    public MyService(ApplicationContext context) {
        this.context = context;
    }
 
    public Object getBeanByName(String beanName) {
        return context.getBean(beanName);
    }
 
    public <T> T getBeanByType(Class<T> beanType) {
        return context.getBean(beanType);
    }
}